# SPDX-License-Identifier: GPL-2.0
#
# Makefile for some libs needed in the kernel.
#
lib-y 		:= hexdump.o div64.o random.o bitmap.o cpumask.o	\
			hweight.o find_bit.o llist.o string_helpers.o kstrtox.o \
			cmdline.o ctype.o sort.o plist.o rbtree.o time.o \
			reciprocal_div.o string.o dec_and_lock.o dump_stack.o \
			usercopy.o params.o vsprintf.o kasprintf.o bsearch.o \
			extable.o timerqueue.o xarray.o idr.o radix-tree.o \
			refcount.o ratelimit.o

obj-$(CONFIG_GENERIC_STRNCPY_FROM_USER) += strncpy_from_user.o
obj-$(CONFIG_GENERIC_STRNLEN_USER) += strnlen_user.o

libfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o \
	       fdt_empty_tree.o
$(foreach file, $(libfdt_files), \
	$(eval CFLAGS_$(file) = -I $(srctree)/scripts/dtc/libfdt))
lib-$(CONFIG_LIBFDT) += $(libfdt_files)

lib-$(CONFIG_BITREVERSE) += bitrev.o
lib-$(CONFIG_CRC32)	+= crc32.o

hostprogs	:= gen_crc32table
clean-files	:= crc32table.h

$(obj)/crc32.o: $(obj)/crc32table.h

quiet_cmd_crc32 = GEN     $@
      cmd_crc32 = $< > $@

$(obj)/crc32table.h: $(obj)/gen_crc32table
	$(call cmd,crc32)
